package com.cs.study.homework._0226;

public class Demo2 {
    public static void main(String[] args) {
        INoReturnNoParam iNoReturnNoParam = () -> {
            System.out.println("testA方法的子实现");
        };
        iNoReturnNoParam.test();

        INoReturnOneParam iNoReturnOneParam = a -> {
            System.out.println(a + 1);
        };
        iNoReturnOneParam.test(5);

        INoReturnTwoParam iNoReturnTwoParam = (a,b)->{
            System.out.println(a+b);
        };
        iNoReturnTwoParam.test(5,10);

        IHasReturnNoParam iHasReturnNoParam =()->{
            System.out.println("hello");
            return 1;
        };
        iHasReturnNoParam.test();

        IHasReturnOneParam iHasReturnOneParam =a->{
            System.out.println(a);
            return 1;
        };
        iHasReturnOneParam.method(10);

        IHasReturnTwoParam iHasReturnTwoParam =  (a,b)->{
            int c = a+b;
            return c;
        };
        iHasReturnTwoParam.test(5,10);



    }
}


//无返回值无参数的功能接口
@FunctionalInterface
interface INoReturnNoParam {
    void test();
}

//无返回值有一个参数的功能接口
@FunctionalInterface
interface INoReturnOneParam {
    void test(int a);
}

//无返回值两个参数的功能接口
@FunctionalInterface
interface INoReturnTwoParam {
    void test(int a, int b);
}

//有返回值无参数的功能接口
@FunctionalInterface
interface IHasReturnNoParam {
    int test();
}

//有返回值一个参数的功能接口
@FunctionalInterface
interface IHasReturnOneParam {
    int method(int a);
}

//有返回值两个参数的功能接口
@FunctionalInterface
interface IHasReturnTwoParam {
    int test(int a, int b);
}